
import axios from 'axios';

/**
 * 维修单
 */
export class RepairOrderService {
    // 分页查询列表
    static findRepairOrders (queryParams) {
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrders',
            method: 'POST',
            data: queryParams
        });
    }

    //根据ID查询指定的维修单
    static findRepairOrder (repairOrderId) {
        const query = {
            repairOrderId
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrder',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(包含外键名称)
    static findRepairOrderForView (repairOrderId) {
        const query = {
            repairOrderId
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrderForView',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(包含外键名称)
    static findRepairOrderForEdit (repairOrderId) {
        const query = {
            repairOrderId
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrderForEdit',
            method: 'POST',
            params: query,
        });
    }

    //根据ID查询指定的维修单(只提取ID 和 Name)
    static findRepairOrdersWithIdNameById (repairOrderId) {
        const query = {
            repairOrderId
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrdersWithIdNameById',
            method: 'POST',
            params: query,
        });
    }

    //根据名称查询维修单集合(只提取ID 和 Name)
    static findRepairOrdersWithIdNameByName (repairOrderName) {
        const query = {
            repairOrderName
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/findRepairOrdersWithIdNameByName',
            method: 'POST',
            params: query,
        });
    }

    //新增保存维修单
    static saveRepairOrder (repairOrder) {
        const query = {}
        return axios({
            url: '/repair/repairManagement/RepairOrder/saveRepairOrder',
            method: 'POST',
            params: query,
            data: repairOrder
        });
    }

    //修改保存维修单
    static updateRepairOrder (repairOrder) {
        const query = {}
        return axios({
            url: '/repair/repairManagement/RepairOrder/updateRepairOrder',
            method: 'POST',
            params: query,
            data: repairOrder
        });
    }

    //根据ID查询指定的维修单(只提取ID 和 Name)
    static deleteRepairOrder (repairOrderId) {
        const query = {
            repairOrderId
        }
        return axios({
            url: '/repair/repairManagement/RepairOrder/deleteRepairOrder',
            method: 'POST',
            params: query,
        });
    }
    static getConfigByName(configName){
      const query = {
        configName
      }
      return axios({
        url: '/sys/con/getConfigByName',
        method: 'POST',
        params: query,
      });
    }

  static updateConfig(config) {
    const query = {}
    return axios({
      url: '/sys/con/updateConfig',
      method: 'POST',
      params: query,
      data: config
    });
  }
  //派单
  static dispatch (userId,repairOrderId) {
    const query = {
      userId,
      repairOrderId
    }
    return axios({
      url: '/repair/repairManagement/RepairOrder/dispatch',
      method: 'POST',
      params: query,
    });
  }

  static countOrders() {
    const query = {
    }
    return axios({
      url: '/repair/repairManagement/RepairOrder/countOrders',
      method: 'POST',
      params: query,
    });
  }

  static countRepairDeviceType() {
    const query = {}
    return axios({
      url: '/repair/repairManagement/RepairOrder/countRepairDeviceType',
      method: 'POST',
      params: query,
    });
  }

  static countRepairFaultTypeByDeviceType(deviceType) {
    const query = {
      deviceType
    }
    return axios({
      url: '/repair/repairManagement/RepairOrder/countRepairFaultTypeByDeviceType',
      method: 'POST',
      params: query,
    });
  }
}
